﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Training.Presentation
{
    public static class Validation
    {
        public static decimal ValidateReadLineDecimal(string message = "CAST ERROR, Enter correct Decimal Value (110001.44)")
        {
            decimal _decimal = -1;
            while (!decimal.TryParse(Console.ReadLine(), out _decimal))
                Console.WriteLine(message);

            return _decimal;
        }

        public static int ValidateReadLineInteger(string message = "CAST ERROR, Enter correct Integer Value")
        {
            var _int = -1;
            while (!int.TryParse(Console.ReadLine(), out _int))
                Console.WriteLine(message);

            return _int;
        }

        public static DateTime ValidateReadLineDateTime(string message = "CAST ERROR, Enter correct Datetime Value (dd/mm/yyyy)")
        {
            var _date = new DateTime();
            while (!DateTime.TryParse(Console.ReadLine(), out _date))
                Console.WriteLine(message);

            return _date;
        }
    }
}
